package net;

import java.io.*;
import java.util.*;
import model.Location;
import model.TockConstants;

public class TockPacket implements Serializable, TockConstants {
	public static final long serialVersionUID = 0; // What the hell is this?
	
	public static final int REGISTER = 0;
	public static final int CHAT = 1;
	public static final int MOVE = 2;
	public static final int UPDATE = 3;
	public static final int EXIT = 4;
	public static final int SIT = 5;
	public static final int STAND = 6;
	public static final int CREATE_GAME = 7;
	public static final int JOIN_GAME = 8;
	public static final int LIST_GAMES = 9;
	
	private String		sender;
	private String 		message;
	private int 		id;
	private int			card;
	private Location	pieceSource;
	private Location	pieceDest;
	private int 		movePacketType;
	private ArrayList<Location>	sevenMoves; // Size should be a multiple of
	private int			gameNum; //ID of the game we are playing
	
		
	public TockPacket(String sender, String message, int gameNum) {
		this(sender, message, CHAT, -1, null, null, null, MOVE_PACKET_TYPE_NORMAL, gameNum);
	}	
	public TockPacket(String sender, int card,
					Location pieceSource, Location pieceDest, ArrayList<Location> sevenMoves, int movePacketType, int gameNum) {
		this(sender, "", MOVE, card, pieceSource, pieceDest, sevenMoves, movePacketType, gameNum);
	}	
	public TockPacket(String sender, int gameNum) {
		this(sender, "", REGISTER, -1, null, null, null, MOVE_PACKET_TYPE_NORMAL, gameNum);
	}
	public TockPacket(String sender, int notNeeded, int gameNum) {
		this(sender, "", EXIT, -1, null, null, null, MOVE_PACKET_TYPE_NORMAL, gameNum);
	}
	public TockPacket(String sender, boolean notNeeded, int gameNum) {
		this(sender, "", UPDATE, -1, null, null, null, MOVE_PACKET_TYPE_NORMAL, gameNum);
	}	
	
	public TockPacket(String sender, String message, int id, int card, Location pieceSource, Location pieceDest, 
			ArrayList<Location> sevenMoves, int movePacketType, int gameNum) {
		this.sender = sender;
		this.message = message;
		this.id = id;
		this.card = card;
		this.pieceSource = pieceSource;
		this.pieceDest = pieceDest;
		this.movePacketType = movePacketType;
		this.sevenMoves = sevenMoves;
		this.gameNum = gameNum;
	}
	
	public String getSender() {return sender;}
	public String getMessage() {return message;}
	public int getID() {return id;}
	public int getCard() {return card;}
	public Location getPieceSource() {return pieceSource;}
	public Location getPieceDest() {return pieceDest;}
	public int getMovePacketType() {return movePacketType;}
	public ArrayList<Location> getSevenMoves() {return sevenMoves;}
	public int getGameNum() {return gameNum; }
	
	public String toString() {
		String theID = "";
		if (id == REGISTER) theID = "Register";
		if (id == MOVE) theID = "Move";
		if (id == CHAT) theID = "Chat";
		if (id == UPDATE) theID = "Update";
		if (id == EXIT) theID = "Exit";
		if (id == SIT) theID = "Sit";
		if (id == STAND) theID = "Stand";
		if (id == CREATE_GAME) theID = "Create Game";
		if (id == JOIN_GAME) theID = "Join Game";
		if (id == LIST_GAMES) theID = "List Games";
		return theID + " Packet";
	}
}
	
